The matrix you gave isn't a rotation matrix, it's a reflection matrix because its determinant is -1. See the definition on Wikipedia. You can tell something isn't right because you should get a unit quaternion, and yet the one you're getting back only has length 1/sqrt(2).
Up vote 4 down vote favorite 1 share g+ share fb share tw.
I have a box defined by 8 points. From those points, I calculate axes and create rotation matrix as follows: axis0, axis1, axis2 mat = { axis0. X axis1.
X axis2. X 0 axis0. Y axis1.
Y axis2. Y 0 axis0. Z axis1.
Z axis2. Z 0 0 0 0 1 } I have particular rotation matrix: { -1 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 1 } As best of my knowledge, this is a valid rotation matrix. Its inversion is equal to its transposition.
Now I would like to store this matrix as a quaternion. But later, I need rotation matrix to be recreated from this quaternion. I believe that convertsion from matrix to quaternion and back to matrix should be an identity transform and I should get the same matrix that I had in the beginning (maybe with very small numerical errors).
But this seems not to be the case. Both SlimDX (C#) and my propertiary math library (C++) return invalid matrix. First, quaternion that I receive: C#: 0, 0, 0.70710676908493, 0 C++: 0, -0.707107, 0, 0 And matrix created from this quaternion: C#: 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 C++: 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 Why is this wrong?
I've also tried this: cache-www.intel.com/cd/00/00/29/37/29374... but it gave me bad results as well. Math 3d geometry 3d-graphics link|improve this question edited Jun 6 '11 at 16:54 asked Jun 6 '11 at 13:54Jerry755.
– ultimatebuster Jun 6 '11 at 14:02 I don't think that numeric errors would cause vector to be completly zeroed. – Jerry Jun 6 '11 at 14:04 Have you checked if the libraries expect "row major" or "column major" layouts internally? – S.C. Madsen Jun 6 '11 at 15:39 It's not really an issue.
Transposed rotation matrix is also a rotation matrix. But yes, all code uses the same (column major) order. – Jerry Jun 6 '11 at 15:53.
1 You are right, I was missing that point! But the question remain, how can I convert 3 axes into a rotation matrix/quaternion? I can swap columns of this matrix and I can negate any column of this matrix (because I am calculating a tangent frame of a box -- I can manipulare axes order and/or direction because I can update dimensions of the box accrodingly).
– Jerry Jun 6 '11 at 18:46 2 Your third axis isn't actually independent, then. Try computing it as the cross product of the first two axes (which, for your example, gives axis2 = (0,-1,0). That should always give you a proper rotation matrix.
– Ray Jun 6 '11 at 18:56 Thank you, it is indeed a good solution. – Jerry Jun 6 '11 at 19:57.
Try using a 4x4 matrix. I'm not matrix math expert, but I've never used 3x3 matrices when dealing with 3D graphics. I believe the extra dimension is for normalization, or something like that.
1 Internally I'm using 4x4 matrices but the last row/column are always 0 0 0 1 for rotation matrices. – Jerry Jun 6 '11 at 14:01 What do you mean by "internally"? Your posted code is using 3x3 matrices.
Do you mean your library automatically converts the 3x3 data to 4x4 when doing the actual multiplication? – MikeWyatt Jun 6 '11 at 14:15 2 I use 4x4 matrices for all calculations. I posted 3x3 matrices because last row is irrelevant.
{ -1 0 0, 0 0 1, 0 -1 0 } is really a { -1 0 0 0 , 0 0 1 0, 0 -1 0 0, 0 0 0 1}, same for others. But I've updated question since what you suggest (wrong auto conversion) would be a possible error, however this is not the case here. – Jerry Jun 6 '11 at 14:16 2 4x4 matrices are used to emulate 3D affine transformations.
Matrix multiplication is a linear transformation, so the origin of one vector space always maps to the origin of another which prevents translation from occuring. By adding an extra dimension, and ensuring all vectors are away from the origin (using vectors of the form x y z 1), you can simulate 3D translation (affine transformations) using 4D linear transformations. That's why 3D graphics typically use 4x4 matrices with 4D vectors.
Since rotation is a linear transformation, it is frequently represented by a 3x3 matrix. – andand Jun 6 '11 at 14:20.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.